Allow editing the HTML for the remove_button plugin#1050
Open
neilvcarvalho wants to merge 3 commits into
Open
Conversation
The `remove_button` plugin currently uses a `javascript:void(0)` link that doesn't work well with a strict CSP, requiring unsafe CSP directives for them to work. Inspired by how the `clear_button` plugin works, this commit replaces the `<a>` element with a `<div role="button">` element behind an `html` option that can be overridden. This will ensure that any application that can switch it for a proper button element can do it on the application side.
xJuvi
approved these changes
Jun 9, 2026
Author
|
I built the plugin using this code and imported the plugin manually (instead of using the Diff to the original build: https://gist.github.com/neilvcarvalho/65c7608a1ef5520c0a17f55bc4e6ee8d/revisions |
NicolasCARPi
requested changes
Jun 9, 2026
| tabindex : -1, | ||
| role : 'button', | ||
| html : (data:RBOptions) => { | ||
| return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">${data.label}</div>`; |
Collaborator
There was a problem hiding this comment.
this can open the door to XSS. Prefer something like:
html : (data:RBOptions) => {
const el = document.createElement('div');
el.className = data.className || '';
el.title = data.title || '';
el.setAttribute('role', data.role || 'button');
el.tabIndex = data.tabindex ?? -1;
el.textContent = data.label || '';
return el;
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
remove_buttonplugin currently uses ajavascript:void(0)link that doesn't work well with a strict CSP, requiring unsafe CSP directives for them to work.Inspired by how the
clear_buttonplugin works, this Pull Request replaces the<a>element with a<div role="button">element behind anhtmloption that can be overridden. This will ensure that any application that can switch it for a proper button element can do it on the application side.As part of this work, an unused
appendoption was removed from the plugin. It was previously used by Selectize, and became a dead code path 6 years ago on 1cb332c.